<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UserAddRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username'=>'required|unique:user,username|max:11|min:11|string|regex:/^1[3456789]\d{9}$/',
            'password'=>'required|min:6|max:16|string',
            'nickname'=>'required|max:20|string',
            'company_name'=>'required|max:50|string|unique:user,company_name',
            'status'=>[
                'required',
                Rule::in([0,1])
            ]
        ];
    }

    public function attributes()
    {
        return [
            'username'=>'手机号',
            'password'=>'密码',
            'nickname'=>'姓名',
            'company_name'=>'公司名',
            'status'=>'用户状态'
        ];
    }
}
